<!DOCTYPE html>
<html>
<head>
    <meta charset='UTF-8'>
    <title>Document</title>
    <style>
        .demo{
            background-color: palevioletred;
        }
    </style>
</head>
<body>
    <button id="btn">点击创建输入框</button>
    <script>
        const btn = document.getElementById('btn')
        btn.onclick = ()=>{
            const input = document.createElement('input')

            input.className = 'demo'
            input.value = '人来人往'
            input.onclick = ()=>{alert(1)}

            //将input放入页面Body中
            document.body.appendChild(input)
            input.focus()//input在页面中才可以获取焦点

            console.log(input.parentElement)

        }
    </script>

</body>
</html>